package cn.eshore.bnet.bpm.dto;

import java.util.Date;

import org.jbpm.graph.exe.ProcessInstance;
import org.jbpm.graph.exe.Token;

public class ProcessInstanceDTO {
    public ProcessInstanceDTO(ProcessInstance processInstance) {
        id = processInstance.getId();
        processDefintionId = processInstance.getProcessDefinition().getId();
        businessKey = processInstance.getKey();
        rootTokenId = processInstance.getRootToken().getId();
        Token superProcessToken = processInstance.getSuperProcessToken();
        if (superProcessToken != null) {
            superProcessTokenId = superProcessToken.getId();
        }
        end = processInstance.getEnd();
        start = processInstance.getStart();
        version = processInstance.getVersion();
        isSuspended = processInstance.isSuspended();

    }

    long id;

    // ??
    int version;

    protected Date start;

    protected Date end;

    protected long rootTokenId;

    protected long superProcessTokenId;

    protected boolean isSuspended;

    /**
     * 业务主键，例如受理号
     */
    protected String businessKey;

    private long processDefintionId;
    
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public int getVersion() {
        return version;
    }

    public void setVersion(int version) {
        this.version = version;
    }

    public Date getStart() {
        return start;
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        this.end = end;
    }

    public long getRootTokenId() {
        return rootTokenId;
    }

    public void setRootTokenId(long rootTokenId) {
        this.rootTokenId = rootTokenId;
    }

    public long getSuperProcessTokenId() {
        return superProcessTokenId;
    }

    public void setSuperProcessTokenId(long superProcessTokenId) {
        this.superProcessTokenId = superProcessTokenId;
    }

    public boolean isSuspended() {
        return isSuspended;
    }

    public void setSuspended(boolean isSuspended) {
        this.isSuspended = isSuspended;
    }

    public String getBusinessKey() {
        return businessKey;
    }

    public void setBusinessKey(String businessKey) {
        this.businessKey = businessKey;
    }

    public long getProcessDefintionId() {
        return processDefintionId;
    }

    public void setProcessDefintionId(long processDefintionId) {
        this.processDefintionId = processDefintionId;
    }
}
